import {defHttp} from '/@/utils/http/axios';
import { useMessage } from "/@/hooks/web/useMessage";

const { createConfirm } = useMessage();

enum Api {
  list = '/TbJobGuardianHeadquarters/tbJobGuardianHeadquarters/list',
  save= '/TbJobGuardianHeadquarters/tbJobGuardianHeadquarters/add',
  edit= '/TbJobGuardianHeadquarters/tbJobGuardianHeadquarters/edit',
  deleteOne = '/TbJobGuardianHeadquarters/tbJobGuardianHeadquarters/delete',
  deleteBatch = '/TbJobGuardianHeadquarters/tbJobGuardianHeadquarters/deleteBatch',
  importExcel = '/TbJobGuardianHeadquarters/tbJobGuardianHeadquarters/importExcel',
  exportXls = '/TbJobGuardianHeadquarters/tbJobGuardianHeadquarters/exportXls',
  tbJobGuardianCertificateList = '/TbJobGuardianHeadquarters/tbJobGuardianHeadquarters/listTbJobGuardianCertificateByMainId',
  tbJobGuardianCertificateSave= '/TbJobGuardianHeadquarters/tbJobGuardianHeadquarters/addTbJobGuardianCertificate',
  tbJobGuardianCertificateEdit= '/TbJobGuardianHeadquarters/tbJobGuardianHeadquarters/editTbJobGuardianCertificate',
  tbJobGuardianCertificateDelete = '/TbJobGuardianHeadquarters/tbJobGuardianHeadquarters/deleteTbJobGuardianCertificate',
  tbJobGuardianCertificateDeleteBatch = '/TbJobGuardianHeadquarters/tbJobGuardianHeadquarters/deleteBatchTbJobGuardianCertificate',
  tbJobGuardianWorktypeList = '/TbJobGuardianHeadquarters/tbJobGuardianHeadquarters/listTbJobGuardianWorktypeByMainId',
  tbJobGuardianWorktypeSave= '/TbJobGuardianHeadquarters/tbJobGuardianHeadquarters/addTbJobGuardianWorktype',
  tbJobGuardianWorktypeEdit= '/TbJobGuardianHeadquarters/tbJobGuardianHeadquarters/editTbJobGuardianWorktype',
  tbJobGuardianWorktypeDelete = '/TbJobGuardianHeadquarters/tbJobGuardianHeadquarters/deleteTbJobGuardianWorktype',
  tbJobGuardianWorktypeDeleteBatch = '/TbJobGuardianHeadquarters/tbJobGuardianHeadquarters/deleteBatchTbJobGuardianWorktype',
  
  queryJointPageList = '/TbJobGuardianHeadquarters/tbJobGuardianHeadquarters/queryJointPageList'
}
/**
 * 导出api
 * @param params
 */
export const getExportUrl = Api.exportXls;

/**
 * 导入api
 */
export const getImportUrl = Api.importExcel;

/**
 * 列表接口
 * @param params
 */
export const list = (params) =>
  defHttp.get({ url: Api.list, params });

/**
 * 删除单个
 */
export const deleteOne = (params,handleSuccess) => {
  return defHttp.delete({ url: Api.deleteOne, params }, { joinParamsToUrl: true }).then(() => {
    handleSuccess();
  });
}

/**
 * 批量删除
 * @param params
 */
export const batchDelete = (params, handleSuccess) => {
  createConfirm({
    iconType: 'warning',
    title: '确认删除',
    content: '是否删除选中数据',
    okText: '确认',
    cancelText: '取消',
    onOk: () => {
      return defHttp.delete({ url: Api.deleteBatch, data: params }, { joinParamsToUrl: true }).then(() => {
        handleSuccess();
      });
    }
  });
}

/**
 * 保存或者更新
 * @param params
 */
export const saveOrUpdate = (params, isUpdate) => {
  let url = isUpdate ? Api.edit : Api.save;
  return defHttp.post({ url: url, params },{ isTransformResponse: false });
}
  
/**
 * 列表接口
 * @param params
 */
export const tbJobGuardianCertificateList = (params) => {
  if(params['jobGuardianId']){
    return defHttp.get({ url: Api.tbJobGuardianCertificateList, params });
  }
  return Promise.resolve({});
}

/**
 * 删除单个
 */
export const tbJobGuardianCertificateDelete = (params,handleSuccess) => {
  return defHttp.delete({ url: Api.tbJobGuardianCertificateDelete, params }, { joinParamsToUrl: true }).then(() => {
    handleSuccess();
  });
}

/**
 * 批量删除
 * @param params
 */
export const tbJobGuardianCertificateDeleteBatch = (params, handleSuccess) => {
  createConfirm({
    iconType: 'warning',
    title: '确认删除',
    content: '是否删除选中数据',
    okText: '确认',
    cancelText: '取消',
    onOk: () => {
      return defHttp.delete({ url: Api.tbJobGuardianCertificateDeleteBatch, data: params }, { joinParamsToUrl: true }).then(() => {
        handleSuccess();
      });
    }
  });
}

/**
 * 保存或者更新
 * @param params
 */
export const  tbJobGuardianCertificateSaveOrUpdate = (params, isUpdate) => {
  let url = isUpdate ? Api.tbJobGuardianCertificateEdit : Api.tbJobGuardianCertificateSave;
  return defHttp.post({ url: url, params },{ isTransformResponse: false });
}

/**
 * 导入
 */
export const tbJobGuardianCertificateImportUrl = '/TbJobGuardianHeadquarters/tbJobGuardianHeadquarters/importTbJobGuardianCertificate'

/**
 * 导出
 */
export const tbJobGuardianCertificateExportXlsUrl = '/TbJobGuardianHeadquarters/tbJobGuardianHeadquarters/exportTbJobGuardianCertificate'
  
/**
 * 列表接口
 * @param params
 */
export const tbJobGuardianWorktypeList = (params) => {
  if(params['jobGuardianId']){
    return defHttp.get({ url: Api.tbJobGuardianWorktypeList, params });
  }
  return Promise.resolve({});
}

/**
 * 删除单个
 */
export const tbJobGuardianWorktypeDelete = (params,handleSuccess) => {
  return defHttp.delete({ url: Api.tbJobGuardianWorktypeDelete, params }, { joinParamsToUrl: true }).then(() => {
    handleSuccess();
  });
}

/**
 * 批量删除
 * @param params
 */
export const tbJobGuardianWorktypeDeleteBatch = (params, handleSuccess) => {
  createConfirm({
    iconType: 'warning',
    title: '确认删除',
    content: '是否删除选中数据',
    okText: '确认',
    cancelText: '取消',
    onOk: () => {
      return defHttp.delete({ url: Api.tbJobGuardianWorktypeDeleteBatch, data: params }, { joinParamsToUrl: true }).then(() => {
        handleSuccess();
      });
    }
  });
}

/**
 * 保存或者更新
 * @param params
 */
export const  tbJobGuardianWorktypeSaveOrUpdate = (params, isUpdate) => {
  let url = isUpdate ? Api.tbJobGuardianWorktypeEdit : Api.tbJobGuardianWorktypeSave;
  return defHttp.post({ url: url, params },{ isTransformResponse: false });
}

/**
 * 导入
 */
export const tbJobGuardianWorktypeImportUrl = '/TbJobGuardianHeadquarters/tbJobGuardianHeadquarters/importTbJobGuardianWorktype'

/**
 * 导出
 */
export const tbJobGuardianWorktypeExportXlsUrl = '/TbJobGuardianHeadquarters/tbJobGuardianHeadquarters/exportTbJobGuardianWorktype'

/**
 * 列表接口
 * @param params
 */
export const queryJointPageList = (params) =>
  defHttp.get({ url: Api.queryJointPageList, params });
